package nero.yncc.com.createart.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;

import nero.yncc.com.createart.R;
import nero.yncc.com.createart.adapter.AdapterMyOrder;
import nero.yncc.com.createart.base.BaseActivity;
import nero.yncc.com.createart.bean.BeanOrder;
import nero.yncc.com.createart.fragment.FragmentMyOrder;

/**
 * Created by nero on 17-6-30.
 */

@ContentView(R.layout.activity_my_order)
public class ActivityMyOrder extends BaseActivity {
    @ViewInject(R.id.tv_all)
    TextView tv_all;
    @ViewInject(R.id.tv_waitpay)
    TextView tv_waitpay;
    @ViewInject(R.id.tv_waitfa)
    TextView tv_waitfa;
    @ViewInject(R.id.tv_waitget)
    TextView tv_waitget;
    @ViewInject(R.id.tv_waitcommit)
    TextView tv_waitcommit;

    @ViewInject(R.id.vp_main)
    ViewPager vp_main;

    AdapterMyOrder adapterMyOrder;
    ArrayList<BeanOrder> arrayList;

    @Override
    protected void initData() {
        super.initData();
        arrayList=new ArrayList<>();
        adapterMyOrder=new AdapterMyOrder(mContext,arrayList);
//        rc_list.setLayoutManager(new LinearLayoutManager(mContext,LinearLayoutManager.VERTICAL,false));
//        rc_list.setAdapter(adapterMyOrder);
    }

    @Override
    protected void initView() {
        super.initView();
        setTitleBarTitle("我的订单");
        change(tv_all);

    }

    @Override
    protected void initListener() {
        super.initListener();
        tv_all.setOnClickListener(this);
        tv_waitpay.setOnClickListener(this);
        tv_waitfa.setOnClickListener(this);
        tv_waitget.setOnClickListener(this);
        tv_waitcommit.setOnClickListener(this);
        vp_main.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                FragmentMyOrder fragmentMyOrder=new FragmentMyOrder();
                Bundle bundle=new Bundle();
                bundle.putInt("state",position);
                fragmentMyOrder.setArguments(bundle);
                return fragmentMyOrder;
            }

            @Override
            public int getCount() {
                return 5;
            }
        });
    }

    @Override
    protected void doClick(int id) {
        super.doClick(id);
        switch (id){
            case R.id.tv_all:
                change(tv_all);
                break;
            case R.id.tv_waitpay:
                change(tv_waitpay);
                break;
            case R.id.tv_waitfa:
                change(tv_waitfa);
                break;
            case R.id.tv_waitget:
                change(tv_waitget);
                break;
            case R.id.tv_waitcommit:
                change(tv_waitcommit);
                break;

        }
    }

    private void change(TextView tv_now){
        tv_all.setBackgroundResource(R.drawable.tv_down);
        tv_waitpay.setBackgroundResource(R.drawable.tv_down);
        tv_waitfa.setBackgroundResource(R.drawable.tv_down);
        tv_waitget.setBackgroundResource(R.drawable.tv_down);
        tv_waitcommit.setBackgroundResource(R.drawable.tv_down);

        tv_now.setBackgroundResource(R.drawable.tv_yellow_down);


    }
}
